
#include "stdafx.h"
#include "Server.h"
#pragma once;
using namespace std;

vector<Server*>  Server::listServer;

Server* Server::seekIdleServer()
{
	if(listServer.size()==0)
		Server::createListServer();
	for each(Server* server in listServer)
	{
		if(server->isIdle)
		{
			server->isIdle = false;
			return server;
		}
	}
	return NULL;
}

Server* Server::seekIdleSuperServer()
{
	if(listServer.size()==0)
		Server::createListServer();
	for each(Server* server in listServer)
	{
		if(server->isIdle && server->isSuperServer)
		{
			server->isIdle = false;
			return server;
		}
	}
	return NULL;
}

double Server::caculateProcessTime(double doPhucTap)
{
	return (doPhucTap/(this->tocDoXuLy*1024));
}

double Server::cauculatePrice(double processTime)
{
	return processTime*this->donGiaThue;
}


void Server::insertServer(int sTT, string serverName, double tocDoXuLy, double donGiaThue, bool isSuperServer)
{
	listServer.push_back(new Server(sTT,serverName,tocDoXuLy,donGiaThue,isSuperServer));
}